package com.enuo.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.NotBlank;

/**
 * @ClassName: MenuItem 
 * @Description: TODO(Entity - 子菜单) 
 * @author Charles 
 * @date 2017年11月21日 下午1:47:52 
 * @version 1.0
 */
@Entity
@Table(name = "menu_item")
public class MenuItem extends OrderEntity
{
    /** 
     * @Fields serialVersionUID : TODO(用一句话描述这个变量表示什么) 
     */ 
    private static final long serialVersionUID = 2723097627149318860L;

    private Menu menu;

    private String name;

    private String icon;

    /**
     * 权限标识
     */
    private String authority;

    /**
     * 前端访问url
     */
    private String url;

    /**
     * 后端接口路径
     */
    private String path;
    
    /** 角色 */
    private List<Role> roles = new ArrayList<Role>();
    
    // Property accessors

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "menu", nullable = false)
    public Menu getMenu()
    {
        return this.menu;
    }

    public void setMenu(Menu menu)
    {
        this.menu = menu;
    }

    @NotBlank
    @Column(name = "name", unique = true, nullable = false)
    public String getName()
    {
        return this.name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    @Column(name = "icon")
    public String getIcon()
    {
        return this.icon;
    }

    public void setIcon(String icon)
    {
        this.icon = icon;
    }

    @NotNull
    @Column(name = "authority", nullable = false)
    public String getAuthority()
    {
        return this.authority;
    }

    public void setAuthority(String authority)
    {
        this.authority = authority;
    }

    @NotBlank
    @Column(name = "url", nullable = false)
    public String getUrl()
    {
        return this.url;
    }

    public void setUrl(String url)
    {
        this.url = url;
    }

    @NotBlank
    @Column(name = "path", nullable = false)
    public String getPath()
    {
        return this.path;
    }

    public void setPath(String path)
    {
        this.path = path;
    }

    @ManyToMany(mappedBy = "menuItems", fetch = FetchType.LAZY)
    public List<Role> getRoles()
    {
        return roles;
    }

    public void setRoles(List<Role> roles)
    {
        this.roles = roles;
    }

}